Component({
  data: {
    show: false,
    title: '提示',
    content: '内容',
    _confirmCallback: undefined as undefined | Function,
    _cancelCallback: undefined as undefined | Function,
  },

  methods: {
    show(params: ModalOptions) {
      this.setData({
        show: true,
        ...params,
        _confirmCallback: params.success,
        _cancelCallback: params.error,
      })
    },

    confirm() {
      this.setData({
        show: false,
      }, () => {
        this.data._confirmCallback && this.data._confirmCallback()
      })
    },

    cancel() {
      this.setData({
        show: false,
      }, () => {
        this.data._cancelCallback && this.data._cancelCallback()
      })
    },
  },
})